package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.DonatedBookRequest;
import com.pgybook.db.entity.domain.DonatedBookRequestEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface DonatedBookRequestMapper {
    int countByExample(DonatedBookRequestEx example);

    int deleteByExample(DonatedBookRequestEx example);

    @Delete({
            "delete from donatedbookrequest",
            "where DONATEDBOOKREQUESTID = #{donatedbookrequestid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long donatedbookrequestid);

    @Insert({
            "insert into donatedbookrequest (CUSTID, STAFFID, ",
            "PURCHASEBOOKID, STATUS, ",
            "CONTENT, CRTTIME, ",
            "UPTTIME)",
            "values (#{custid,jdbcType=BIGINT}, #{staffid,jdbcType=INTEGER}, ",
            "#{purchasebookid,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, ",
            "#{content,jdbcType=VARCHAR}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{upttime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "donatedbookrequestid", before = false, resultType = Long.class)
    int insert(DonatedBookRequest record);

    int insertSelective(DonatedBookRequest record);

    List<DonatedBookRequest> selectByExample(DonatedBookRequestEx example);

    @Select({
            "select",
            "DONATEDBOOKREQUESTID, CUSTID, STAFFID, PURCHASEBOOKID, STATUS, CONTENT, CRTTIME, ",
            "UPTTIME",
            "from donatedbookrequest",
            "where DONATEDBOOKREQUESTID = #{donatedbookrequestid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    DonatedBookRequest selectByPrimaryKey(Long donatedbookrequestid);

    int updateByExampleSelective(@Param("record") DonatedBookRequest record, @Param("example") DonatedBookRequestEx example);

    int updateByExample(@Param("record") DonatedBookRequest record, @Param("example") DonatedBookRequestEx example);

    int updateByPrimaryKeySelective(DonatedBookRequest record);

    @Update({
            "update donatedbookrequest",
            "set CUSTID = #{custid,jdbcType=BIGINT},",
            "STAFFID = #{staffid,jdbcType=INTEGER},",
            "PURCHASEBOOKID = #{purchasebookid,jdbcType=BIGINT},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "CONTENT = #{content,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "UPTTIME = #{upttime,jdbcType=TIMESTAMP}",
            "where DONATEDBOOKREQUESTID = #{donatedbookrequestid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(DonatedBookRequest record);
}
